<?php

namespace common\validate;


class Step extends BaseValidate
{
    // 验证规则
    protected $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.name', 'require|max:128')
            ->append('data.code', 'max:128')
            ->append('data.color', 'require|max:7')
            ->append('data.variable', 'max:8')
            ->append('data.engine', 'max:128')
            ->append('data.batch', 'max:128');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.name', 'max:128')
            ->append('data.code', 'max:128')
            ->append('data.color', 'max:7')
            ->append('data.variable', 'max:8')
            ->append('data.engine', 'max:128')
            ->append('data.batch', 'max:128');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // SelectWithParentCate 验证场景定义
    public function sceneSelectWithParentCate()
    {
        return $this->append('param', 'require')
            ->append('param.fields', 'require');
    }

    // BindReviewWorkflow   验证场景定义
    public function sceneBindReviewWorkflow()
    {
        return $this->append("data_list", "require|array");
    }

    // BindReviewWorkflowItem
    public function sceneBindReviewWorkflowItem()
    {
        return $this
            ->append("review_workflow_id", "require|integer")
            ->append("step_id", "require|integer")
            ->append("step_workflow_id", "require|integer")
            ->append("project_template_id", "require|integer")
            ->append("attr_str", "max:256");
    }

    // ProjectTemplateStepList 验证场景定义
    public function sceneProjectTemplateStepList()
    {
        return $this
            ->append("param", "require")
            ->append("param.project_template_id", "require|integer");
    }
}
